@extends('layouts.master3')
@section("title")
千里码-讨论区
@endsection
@section("css")
    <link href="/css/base.css" rel="stylesheet">
    <link href="/css/discuss.css" rel="stylesheet">
@endsection
@section('style')
<style>
footer{
    position:fixed;
    bottom:0;
}
</style>
@endsection
@section("content")
<?php
use App\Utils;
?>
<div class="contain">
    <form method="POST" action="" accept-charset="UTF-8"><input name="_token" type="hidden" value="{{csrf_token()}}">

        <div class="qz-q">
            <h2>分享文章</h2>
        </div>
        <div class="qz-share-title">
            <span>标题</span> <input type="text" class="share-title" placeholder="请输入原文标题" name="title">
        </div>
        <div class="qz-share-title">
            <span>链接</span> <input type="text" class="share-link" placeholder="请输入原文链接" name="content">
        </div>
        <div class="qz-q-list">
            <span>选择标签</span>
            <select class="select" id="tag" name="filter">
            <option value="任务">任务</option>
            <option value="其他">其他</option>
        </select>
            <select class="select" name="tag">
@foreach($data as $d)
            <option value="{{$d->title}}" @if($tag==$d->title) selected="selected" @endif>{{$d->id}}.{{$d->title}}</option>
@endforeach
            </select>
        </div>
        <div class="clear"></div>
        <div class="qz-share-title">
            <span>推荐理由</span> <input type="text" placeholder="请简述推荐理由" name="suggest">
        </div>
        <div class="clear"></div>
          <input class="btn btn-primary pull-right" type="submit" value="发布">
    </form>
</div>

@endsection
@section('js')
<script>
    $(function() {
        $("#tag").change(function(){
            if($(this).children('option:selected').val()!=="任务"){
                $(this).next("select").hide();
            }
            else{
                $(this).next("select").show();
            }
        })
         $("input.btn[type='submit']").click(function(e){
            e.preventDefault();
            if($(".share-title").val()==="")
            {
                $(".share-title").addClass("tooltipColor");
                        return false;
            }
            else if($(".share-link").val()===""){
                $(".share-link").addClass("tooltipColor");
                return false;
            }
            else{
                $("form").submit();
            }
        });
        $(".qz-share-title input").bind("input propertychange",function(){
           if($(this).val!=="")
           {
               $(this).removeClass("tooltipColor");
           }
        });
    })
</script>
@endsection
